package com.jt.redis;
/*
需求:生成一个自增分布式id
 */
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class IDGenerator {
    @Resource(name = "stringRedisTemplate")
    private ValueOperations valueOperations;

    public Long generater(){
        return valueOperations.increment("id");//自增id
    }

}
